//
//  MGModalView.h
//  Mango
//
//  Created by 胡超 on 2017/11/29.
//  Copyright © 2017年 胡超., ltd. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, MGModalType) {
    MGModalTypeAlert,
    MGModalTypeAlertBottom,
    MGModalTypeCustom,
};

@interface MGModalView : UIView

@property (nonatomic,strong,readonly) UIView *contentView;
@property (nonatomic,strong,readonly) UIView *backgroundView;

@property (nonatomic,readonly) MGModalType  preferredModalType;     // default is MGModalTypeAlert

/** 点击背景dismiss，默认YES*/
@property (nonatomic,assign) BOOL enableTapDismiss;
/** 点击操作穿透背景，默认NO*/
@property (nonatomic,assign) BOOL enableBackgroundUserInteraction;
/** 在MGModalTypeAlertBottom类型下自动根据safeArea调整高度*/
@property (nonatomic,assign) BOOL automaticallyAdjustsContentViewHeight;
/** 圆角*/
@property (nonatomic,assign) CGFloat cornerRadius;  // default is 0
/** 动画*/
@property (nonatomic,assign) NSTimeInterval animationDuration;
@property (nonatomic,assign) UIViewAnimationCurve animationCurve;

@property (nonatomic,assign,readonly) BOOL isPresented;

/** dismiss回调*/
@property (nonatomic,copy) void(^_Nullable didDismissHandler)(void);

- (instancetype)init;

- (void)presentInView:(UIView *)inView;
- (void)dismiss;

- (void)viewWillPresent;
- (void)viewDidPresent;
- (void)viewWillDismiss;
- (void)viewDidDismiss;

- (void)onTapGesture:(UITapGestureRecognizer *)gesture;

#pragma mark - 子类实现
/** 自定义present动画*/
- (void)contentViewPresentCustomAnimation:(void(^)(void))completion;
/** 自定义dismiss动画*/
- (void)contentViewDismissCustomAnimation:(void(^)(void))completion;

@end

NS_ASSUME_NONNULL_END
